@echo off

cls

if "%setenv%" == "" (
	call setenv.bat
)

REM REM Patch Winsetup from cd sources

REM Patch WinSetup.dll on mounted image to allow install Windows XP/2003  - Try Vista or Win7 64 bits Setup 
"%~dp0tools\bbe\%ARCH%\bbe.exe" -b "/\x48\x89\x4C\x24\x08\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x81\xEC\xD0/:20" -e "s/\x48\x89\x4C\x24\x08\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x81\xEC\xD0/\xC3\xC0\x33\x24\x08\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x81\xEC\xD0/"" "Sources\DVD\sources\winsetup.dll" -o "Sources\DVD\sources\winsetup1.dll"

del "Sources\DVD\sources\winsetup.dll"

ren "Sources\DVD\sources\winsetup1.dll" winsetup.dll

REM Patch WinSetup.dll on mounted image to allow install Windows XP/2003  - Try Win8 and Win10 until 1709 64 bits Setup
"%~dp0tools\bbe\%ARCH%\bbe.exe" -b "/\x48\x89\x4C\x24\x08\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\x6C\x24\xD9\x48\x81\xEC\xD0/:25" -e "s/\x48\x89\x4C\x24\x08\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\x6C\x24\xD9\x48\x81\xEC\xD0/\xC3\xC0\x33\x24\x08\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\x6C\x24\xD9\x48\x81\xEC\xD0/"" "Sources\DVD\sources\winsetup.dll" -o "Sources\DVD\sources\winsetup1.dll"

del "Sources\DVD\sources\winsetup.dll"

ren "Sources\DVD\sources\winsetup1.dll" winsetup.dll

REM REM Patch WinSetup.dll on mounted image to allow install Windows XP/2003  - Try Win10 1803 until 1909 64 bits Setup
"%~dp0tools\bbe\%ARCH%\bbe.exe" -b "/\x48\x89\x4C\x24\x08\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\x6C\x24\xF0\x48\x81\xEC\x10/:25" -e "s/\x48\x89\x4C\x24\x08\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\x6C\x24\xF0\x48\x81\xEC\x10/\xC3\xC0\x33\x24\x08\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\x6C\x24\xF0\x48\x81\xEC\x10/"" "Sources\DVD\sources\winsetup.dll" -o "Sources\DVD\sources\winsetup1.dll"

del "Sources\DVD\sources\winsetup.dll"

ren "Sources\DVD\sources\winsetup1.dll" winsetup.dll

REM Patch WinSetup.dll on mounted image to allow install Windows XP/2003  - Try Win10 2004 until 22H2 64 bits Setup
"%~dp0tools\bbe\%ARCH%\bbe.exe" -b "/\x48\x89\x4C\x24\x08\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\x6C\x24\xE0\x48\x81\xEC\x20/:25" -e "s/\x48\x89\x4C\x24\x08\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\x6C\x24\xE0\x48\x81\xEC\x20/\xC3\xC0\x33\x24\x08\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\x6C\x24\xE0\x48\x81\xEC\x20/"" "Sources\DVD\sources\winsetup.dll" -o "Sources\DVD\sources\winsetup1.dll"

del "Sources\DVD\sources\winsetup.dll"

ren "Sources\DVD\sources\winsetup1.dll" winsetup.dll

REM Patch WinSetup.dll on mounted image to allow install Windows XP/2003  - Try Win11 Setup
"%~dp0tools\bbe\%ARCH%\bbe.exe" -b "/\x48\x89\x58\x10\x48\x89\x70\x18\x48\x89\x78\x20\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\x68\xA1\x48\x81\xEC\x00/:29" -e "s/\x48\x89\x58\x10\x48\x89\x70\x18\x48\x89\x78\x20\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\x68\xA1\x48\x81\xEC\x00/\xC3\xC0\x33\x10\x48\x89\x70\x18\x48\x89\x78\x20\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\x68\xA1\x48\x81\xEC\x00/"" "Sources\DVD\sources\winsetup.dll" -o "Sources\DVD\sources\winsetup1.dll"
	
del "Sources\DVD\sources\winsetup.dll"

ren "Sources\DVD\sources\winsetup1.dll" winsetup.dll	